<?php
	require_once("../connect.php");
	function LoadDSPhong()
	{
		$result=mysql_query("select map,tenp from phong order by map");
		if(mysql_num_rows($result)==0)
			echo "Không có dữ liệu";
		while($row=mysql_fetch_assoc($result))
		{
			echo "<option value='".$row["map"]."'>".$row["tenp"]."</option>";	
		}
		mysql_free_result($result);
		//mysql_close($connect);
	}

	function getIDMax($id,$table)
	{
		$result=mysql_query("select max($id)$id from $table");
		$row=mysql_fetch_assoc($result);
		if($row["$id"]=="")
			return 1;
		else
			return $row["$id"]+1;
	}
	
	function ThemNT($NguoiThue)
	{
		session_start();
		$mant=getIDMax("mant","nguoithue");
		$sql="insert into nguoithue(mant,hoten,hotenkhac,hinh,gioitinh,ngaysinh,noisinh,quequan,dantoc,tongiao,cmnd,noithuongtru,noiohiennay,trinhdo,trinhdochuyenmon,ngoaingu,nghenghiep,tu14t,dangthue,ngayvao,map)values($mant,'".$NguoiThue["HoTen"]."','".$NguoiThue["Nickname"]."','".$_SESSION["imgData"]."','".$NguoiThue["GioiTinh"]."',str_to_date('".$NguoiThue["NgaySinh"]."', '%d/%m/%Y'),'".$NguoiThue["NoiSinh"]."','".$NguoiThue["QueQuan"]."','".$NguoiThue["DanToc"]."','".$NguoiThue["TonGiao"]."','".$NguoiThue["CMND"]."','".$NguoiThue["NoiThuongTru"]."','".$NguoiThue["NoiOHienNay"]."','".$NguoiThue["TrinhDo"]."','".$NguoiThue["TrinhDoChuyenMon"]."','".$NguoiThue["NgoaiNgu"]."','".$NguoiThue["NgheNghiep"]."','".$NguoiThue["Tu14t"]."','1',str_to_date('".$NguoiThue["NgayVao"]."', '%d/%m/%Y'),'".$NguoiThue["MaP"]."')";
		mysql_query($sql);	
		session_destroy();								
	}
	
?>
